# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=beaker
pkgbase="python-${_realname}"
pkgname=("python3-${_realname}" "python2-${_realname}")
pkgver=1.10.0
pkgrel=1
pkgdesc="Caching and sessions WSGI middleware for use with web applications and stand-alone Python scripts and applications"
arch=('i686' 'x86_64')
license=('PSF')
url="http://beaker.groovie.org/"
depends=("python2-setuptools" "python3-setuptools")
source=("${_realname}-${pkgver}.tar.gz"::https://github.com/bbangert/beaker/archive/${pkgver}.tar.gz)
sha256sums=('50d4c24ae8a7015e3a7edf0482cef84c2dd6b2d76eabf441927236bbf4e26eeb')

prepare() {
  cd "${srcdir}"

  cp -a ${_realname}-${pkgver}{,-python2}
}

build() {
  # Build python 3 module
  cd "${srcdir}"/${_realname}-${pkgver}
  sed -i "s#/usr/bin/python#/usr/bin/python3#" beaker/crypto/pbkdf2.py
  python3 setup.py build

  # Build python 2 module
  cd ../${_realname}-${pkgver}-python2
  sed -i "s#/usr/bin/python#/usr/bin/python2#" beaker/crypto/pbkdf2.py
  python2 setup.py build
}

package_python3-beaker() {
  depends=('python>=3.3')

  cd "${srcdir}/${_realname}-${pkgver}"
  python3 setup.py install --prefix=/usr --root="${pkgdir}" --optimize=1 --skip-build
  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/python3-beaker/LICENSE"
}

package_python2-beaker() {
  depends=('python2>=2.7')

  cd "${srcdir}/${_realname}-${pkgver}-python2"
  python2 setup.py install --prefix=/usr --root="${pkgdir}" --optimize=1 --skip-build
  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/python2-beaker/LICENSE"
}
